#include "operatingcenter.hpp"
#include "interface_ada.hpp"
#include <string>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <sstream>
#include<pthread.h>
using namespace std;

	//l'OperatingCenter prend en parametre le nombre de bus qu'il va gerer
	OperatingCenter::OperatingCenter(int maxbus)
	{
		define_max_bus(maxbus);
//CREATION DES BUS_STOP
		bus_Stop bs1 = {1,true};
		bus_Stop bs2 = {2,true};
		bus_Stop bs3 = {3,true};
		bus_Stop bs4 = {4,true};	
		bus_Stop bs5 = {5,true};
		bus_Stop bs6 = {6,true};
		bus_Stop bs7 = {7,true};
		bus_Stop bs8 = {8,true};	
		bus_Stop bs9 = {9,true};
		bus_Stop bs10 = {10,true};
		bus_Stop bs11 = {11,true};
		bus_Stop bs12 = {12,true};	
		bus_Stop bs13 = {13,true};
		bus_Stop bs14 = {14,true};
		bus_Stop bs15 = {15,true};
		bus_Stop bs16 = {16,true};	
		bus_Stop bs17 = {17,true};
		bus_Stop bs18 = {18,true};
		bus_Stop bs19 = {19,true};
		bus_Stop bs20 = {20,true};	

//CREATION DU RESEAU DE BUS_STOP
		Bus_Stop_Line bsl_1 = {bs1, 0.2, 0.27};// avec une vitesse de 45Km/h, le bus mettera 0.27 min (16 secondes) pour parcourir 0.2 Km (200 m)
		Bus_Stop_Line bsl_2 = {bs2, 0.3, 0.4}; // 300 m en 0.4 min (24 secondes)
		Bus_Stop_Line bsl_3 = {bs3, 0.4, 0.53};// 400 m en 0.53 avec une vitesse de 45Km/h
		Bus_Stop_Line bsl_4 = {bs4, 0.3, 0.4}; // 
		Bus_Stop_Line bsl_5 = {bs5, 0.5, 0.66};
		Bus_Stop_Line bsl_6 = {bs6, 0.4, 0.53};
		Bus_Stop_Line bsl_7 = {bs7, 0.2, 0.27};
		Bus_Stop_Line bsl_8 = {bs8, 0.4, 0.53};
		Bus_Stop_Line bsl_9 = {bs9, 0.3, 0.4};
		Bus_Stop_Line bsl_10 = {bs10, 0, 0};
		Bus_Stop_Line bsl_11 = {bs11, 0.5, 0.66};
		Bus_Stop_Line bsl_12 = {bs12, 0.4, 0.53};
		Bus_Stop_Line bsl_13 = {bs13, 0.5, 0.66};
		Bus_Stop_Line bsl_14 = {bs14, 0.3, 0.4};
		Bus_Stop_Line bsl_15 = {bs15, 0.5, 0.66};
		Bus_Stop_Line bsl_16 = {bs16, 0.4, 0.53};
		Bus_Stop_Line bsl_17 = {bs17, 0.3, 0.4};
		Bus_Stop_Line bsl_18 = {bs18, 0.4, 0.53};
		Bus_Stop_Line bsl_19 = {bs19, 0.3, 0.4};
		Bus_Stop_Line bsl_20 = {bs20, 0, 0};
		

		vector<Bus_Stop_Line> bsLine1;
		bsLine1.push_back(bsl_1);
		bsLine1.push_back(bsl_2);
		bsLine1.push_back(bsl_3);
		bsLine1.push_back(bsl_4);
		bsLine1.push_back(bsl_5);
		bsLine1.push_back(bsl_6);
		bsLine1.push_back(bsl_7);
		bsLine1.push_back(bsl_10);
		add_bus_line(bsLine1);

		vector<Bus_Stop_Line> bsLine2;
		bsLine2.push_back(bsl_2);
		bsLine2.push_back(bsl_4);
		bsLine2.push_back(bsl_6);
		bsLine2.push_back(bsl_8);
		bsLine2.push_back(bsl_11);
		bsLine2.push_back(bsl_12);
		bsLine2.push_back(bsl_13);
		bsLine2.push_back(bsl_20);
		add_bus_line(bsLine2);

		vector<Bus_Stop_Line> bsLine3;
		bsLine3.push_back(bsl_3);
		bsLine3.push_back(bsl_5);
		bsLine3.push_back(bsl_7);
		bsLine3.push_back(bsl_8);
		bsLine3.push_back(bsl_9);
		bsLine3.push_back(bsl_11);
		bsLine3.push_back(bsl_12);
		bsLine3.push_back(bsl_10);
		add_bus_line(bsLine3);

		vector<Bus_Stop_Line> bsLine4;
		bsLine4.push_back(bsl_1);
		bsLine4.push_back(bsl_2);
		bsLine4.push_back(bsl_5);
		bsLine4.push_back(bsl_6);
		bsLine4.push_back(bsl_9);
		bsLine4.push_back(bsl_13);
		bsLine4.push_back(bsl_17);
		bsLine4.push_back(bsl_20);
		add_bus_line(bsLine4);

		vector<Bus_Stop_Line> bsLine5;
		bsLine5.push_back(bsl_6);
		bsLine5.push_back(bsl_7);
		bsLine5.push_back(bsl_14);
		bsLine5.push_back(bsl_15);
		bsLine5.push_back(bsl_16);
		bsLine5.push_back(bsl_17);
		bsLine5.push_back(bsl_18);
		bsLine5.push_back(bsl_20);
		add_bus_line(bsLine5);

		vector<Bus_Stop_Line> bsLine6;
		bsLine6.push_back(bsl_12);
		bsLine6.push_back(bsl_13);
		bsLine6.push_back(bsl_14);
		bsLine6.push_back(bsl_15);
		bsLine6.push_back(bsl_16);
		bsLine6.push_back(bsl_17);
		bsLine6.push_back(bsl_19);
		bsLine6.push_back(bsl_20);
		add_bus_line(bsLine6);

		vector<Bus_Stop_Line> bsLine7;
		bsLine7.push_back(bsl_7);
		bsLine7.push_back(bsl_9);
		bsLine7.push_back(bsl_11);
		bsLine7.push_back(bsl_16);
		bsLine7.push_back(bsl_17);
		bsLine7.push_back(bsl_18);
		bsLine7.push_back(bsl_19);
		bsLine7.push_back(bsl_20);
		add_bus_line(bsLine7);

		vector<Bus_Stop_Line> bsLine8;
		bsLine8.push_back(bsl_5);
		bsLine8.push_back(bsl_6);
		bsLine8.push_back(bsl_9);
		bsLine8.push_back(bsl_13);
		bsLine8.push_back(bsl_17);
		bsLine8.push_back(bsl_18);
		bsLine8.push_back(bsl_19);
		bsLine8.push_back(bsl_20);
		add_bus_line(bsLine8);

		vector<Bus_Stop_Line> bsLine9;
		bsLine9.push_back(bsl_2);
		bsLine9.push_back(bsl_5);
		bsLine9.push_back(bsl_6);
		bsLine9.push_back(bsl_8);
		bsLine9.push_back(bsl_9);
		bsLine9.push_back(bsl_13);
		bsLine9.push_back(bsl_15);
		bsLine9.push_back(bsl_20);
		add_bus_line(bsLine9);

		vector<Bus_Stop_Line> bsLine10;
		bsLine10.push_back(bsl_3);
		bsLine10.push_back(bsl_4);
		bsLine10.push_back(bsl_8);
		bsLine10.push_back(bsl_9);
		bsLine10.push_back(bsl_13);
		bsLine10.push_back(bsl_16);
		bsLine10.push_back(bsl_19);
		bsLine10.push_back(bsl_20);
		add_bus_line(bsLine10);
		//initialisation du mutex
		if (pthread_mutex_init(&mutexDispo,NULL)!=0)
			cout<<"\nErreur d'initialisation de mutex!\n";
    }
	
    OperatingCenter* OperatingCenter::getInstance()
    {
    	if(single == NULL)
    	{
      	   	single = new OperatingCenter(MAX_BUS);
    	}
    	return single;
    }
    
    OperatingCenter::~OperatingCenter(){}

    void OperatingCenter::define_max_bus(int m){
	this->maxBus=m;
    }

    void OperatingCenter::add_bus_line(vector<Bus_Stop_Line>& bsl){
	if(BusLine_vector.max_size() - BusLine_vector.size() == 0 ){
	    cout<<"On ne peut pas creer d'autre bus. L'operating Center est Overbooked"<<endl;
	    exit(1);
	} else {
	    BusLine_vector.push_back(bsl);
    	}
    }
    
	// renvoie l'incice dans le tableau du bus stop passe en param
    int OperatingCenter::getIndiceBusStop(int numline, int numBusStop)
    {			
    	unsigned int indice, i;
		for (i = 0; i < BusLine_vector[numline-1].size(); i++)
		{
			if(BusLine_vector[numline-1][i].busStop.idBusStop == numBusStop)
			    indice = i; // indice prend le bon Id de l'arret 
		}
		return indice;
    }
    
    // Envoit a tous les bus stop suivant la position du bus 
    void OperatingCenter::sendPositionBusStops(bool sens_alle, int numline, int numBusStop, T_Schedule* sch)
    {    
    	unsigned int indiceBusStop = getIndiceBusStop(numline, numBusStop);
    	vector<Bus_Stop_Line> ligneBus = BusLine_vector[numline-1];
            		
        // Envoi de la position a l'arret directement suivant
        set_bus_stop_arrival_time (numBusStop,sch);
        
        // Envoi a tous les bus stop suivant	
    	if (sens_alle)
    	{
	    	for (unsigned int i = indiceBusStop+1; i < ligneBus.size()-1 ; i++)	
	    	{
	    		sch->waiting_time += (ligneBus[i]).timeToNextStop/60;
	    		set_bus_stop_arrival_time (ligneBus[i+1].busStop.idBusStop,sch);
	    	}
    	}
	    else
	    {
	    	for (int i = indiceBusStop-1; i >= 0 ; i--)	
	    	{
	    		sch->waiting_time += (ligneBus[i]).timeToNextStop/60;
	    		set_bus_stop_arrival_time (ligneBus[i].busStop.idBusStop,sch);
	    	}	    
	    }
    }
    
    void OperatingCenter::set_bus_pos(int numline, int numBus, struct Position *p, float speed)
    {
    	float timeToNextBusStop, distanceRestante, distanceEntreArret;
		unsigned int idNextBusstop,indice;
		int retour, numBusStop;
		struct T_Schedule sch;
		vector<Bus_Stop_Line> ligneBus = BusLine_vector[numline-1];
		
		if(p->distance!=0)
		{        
	        // On recupere l'indice du bus stop courant dans le tableau
	        indice = getIndiceBusStop(numline, p->id_bus_stop);

			if(p->sens_aller)
			{
			    idNextBusstop     = (ligneBus[indice+1]).busStop.idBusStop;                   // on recupere le PROCHAIN bus stop
			    distanceRestante  = (ligneBus[indice]).distanceWithNextBusStop - p->distance; // on recupere le distance entre les bus stop
			    timeToNextBusStop = (ligneBus[indice]).timeToNextStop;                        // on recupere le temps entre les bus stop
			    distanceEntreArret= (ligneBus[indice]).distanceWithNextBusStop;
			}
			else
			{
				idNextBusstop     = (ligneBus[indice-1]).busStop.idBusStop;                     // on recupere le PROCHAIN bus stop
			    distanceRestante  = (ligneBus[indice-1]).distanceWithNextBusStop - p->distance; // on recupere le distance entre les bus stop
			    timeToNextBusStop = (ligneBus[indice-1]).timeToNextStop;                        // on recupere le temps entre les bus stop
			    distanceEntreArret= (ligneBus[indice-1]).distanceWithNextBusStop;
			}
		
			if( (ligneBus[indice]).busStop.obligatory == true )
			{
				sch.waiting_time = distanceRestante / speed; // le waiting_time est en seconde
	
				//Sauvegarde de la position
				save_position(numline,numBus,p);
				
		    	/*
		    	*    Calcul du waiting time
		    	*     Renvoie 1 si le bus est en avance
		    	*     Renvoie 2 si le bus est en retard
		    	*     Renvoie 0 si le bus est OK 
		    	*/
		    	if(sch.waiting_time * 60 < timeToNextBusStop * 60 - p->time )
		    	{
		        	sch.info = 2;
		        	retour = 2; 
		    	} else if(sch.waiting_time * 60 > timeToNextBusStop * 60 - p->time)
		    	{
		        	sch.info = 1;
		        	retour = 1;
		    	} else if (sch.waiting_time * 60 == timeToNextBusStop * 60 - p->time)
		    	{
		        	sch.info = 0;
		        	retour = 0;
		    	}
		    }
	 
		    //Info pour le prochain arret calculee a partir des param et du tableau 
		    sch.line_number = numline;
				    
		    //Le numero du prochain bus stop:		
		    numBusStop= idNextBusstop;		
			 
			//Transimission des info aux prochains bus stop:
	        sendPositionBusStops(p->sens_aller, numline, numBusStop,&sch);
	        
			//On transmet l'information (retard/avance) au bus
			set_bus_time(numBus,retour);
		}
		BusesHTML(numline,numBus,p,speed);
    }


	int OperatingCenter::announceProblem(int numBus, char *message, Position *_p){
		cout<<"Le bus numero "<<numBus<<" a un probleme de type "<<message<<" a "<<_p->distance * 1000<<" m du BusStop "<< _p->id_bus_stop<<endl;
		cout<<"Nos techniciens travaillent sur les differentes deviations possibles"<<endl;
		//deviation(numBus);
		return 3;
	}

	//Fonction de sauvegarde de la position dans un fichier log_positions
 	void OperatingCenter::save_position(int nl,int nb,struct Position *p)
    {
		 //On prend un jeton s'il y en a
		pthread_mutex_lock(&mutexDispo);
		//Declaration du fichier
		FILE *f;
		//Ouverture du fichier
		f = fopen("log_positions", "a+");
		//Ecriture
		fprintf(f,"\n==============  Operating Center  ============\n");
		fprintf(f,"== Bus numero :   \t\t\t%d\n",nb);
		fprintf(f,"== Ligne numero :   \t\t\t%d\n",nl);
		fprintf(f,"== Position :       \t\t%f m du BusStop %d\n",(p->distance * 1000),p->id_bus_stop);
		if (p->sens_aller)
		fprintf(f,"== Sens :   \t\t\t aller\n");
		else
		fprintf(f,"== Sens :   \t\t\t retour\n");
		//Fermeture du fichier
		fclose(f);
		//On rend le jeton
		pthread_mutex_unlock(&mutexDispo);

	}
//creation de la page d'acceuil en html en fonction du nombre de bus
	void OperatingCenter::WelcomeHTML( int nb)
	{	
		int i=1;
		ostringstream oss;
		ofstream fic("menu.html");
		fic<<"<html>"<<endl;
		fic<<"<head>"<<endl;
		fic<<"<title>Urban Bus Network</title>"<<endl;
		fic<<"<style type=\"text/css\">"<<endl;
		fic<<"<!--"<<endl;
		fic<<"body {background-image: url(pics/bg.jpg);}"<<endl;
		fic<<".style4 {font-size: 24px;color: #FFFFFF;font-weight: bold;}"<<endl;
		fic<<"-->"<<endl;
		fic<<"</style>"<<endl;
		fic<<"</head>"<<endl;
		fic<<"<body>"<<endl;
		fic<<""<<endl;
		while(i<=nb)
		{
		oss.str("");
		fic<<"<p class=\"style4\"><a target=\"contenu\" href=\"bus"<<i<<".html\"><img src=\"pics/bus2.gif\" width=\"49\" height=\"43\" border=\"0\" /></a>"<<i<<"</p>"<<endl;
		oss<<"bus"<<i<<".html";
		ofstream f(oss.str().c_str());f.close();
		i++;
		}
		fic<<"</body>"<<endl;
		fic<<"</html>"<<endl;		
		fic.close();
	}
//creation de la page info bus
	void OperatingCenter::BusesHTML(int numline,int numBus, struct Position *p, float speed)
{
	       float timeToNextBusStop, distanceRestante, distanceEntreArret;
		unsigned int idNextBusstop,indice, idbusstopatteint=0;
		struct T_Schedule sch;
		ostringstream oss;
    		vector<Bus_Stop_Line> ligneBus = BusLine_vector[numline-1];

try{	
		oss<<"bus"<<numBus<<".html";
		ofstream fic(oss.str().c_str());
		
		fic<<"<HTML>\n<HEAD>\n<TITLE>Bus Network : Suivi du bus "<<numBus<<"</TITLE>"<<endl;
		fic<<"<meta http-equiv=\"refresh\" content=\"2;"<<oss.str()<<"\">\n"<<endl;
		fic<<"<!--"<<endl;
		fic<<"body {background-image: url(pics/bg.jpg);}"<<endl;
		fic<<".style1 {font-size: 18px}"<<endl;
		fic<<".style3 {font-size: 20px}"<<endl;
		fic<<"-->"<<endl;
		fic<<"</style>"<<endl;
		fic<<"</HEAD><BODY background=\"pics/bg.jpg\" background-repeat=\"no-repeat\">"<<endl;
		fic<<"<h1 align=\"center\">Operating Center</h1><br><br>"<<endl;
		fic<<"<div align=center><a target=_blank href=bus"<<numBus<<".html><span class=\"style3\">Cliquez ici pour afficher cette page dans une autre fenetre</span></a></div>"<<endl;
		fic<<"<table width=\"788\" border=\"1\" align=\"center\">"<<endl;
		fic<<"<tr><td bordercolor=\"#000000\"><div align=\"center\">Informations du bus </div></td>"<<endl;
		fic<<"<td bordercolor=\"#000000\"><div align=\"center\">Liste des BusStops desservis par le bus </div></td></tr>"<<endl;
		fic<<"<tr><td width=\"386\" bordercolor=\"#000000\"><p class=\"style1\">- Num&eacute;ro du bus : "<<numBus<<"</p>"<<endl;
		fic<<"<p class=\"style1\">- Num&eacute;ro de la ligne de bus : "<<numline<<"</p>"<<endl;
		fic<<"<p class=\"style1\">- Position : "<<p->distance * 1000<<" m du BusStop "<<p->id_bus_stop<<"</p>"<<endl;
		fic<<"<p class=\"style1\">- Demarr&eacute; depuis : "<<p->time<<" secondes</p>"<<endl;
		fic<<"<p class=\"style1\">- Vitesse : "<<speed<<" km/h</p>"<<endl;
        
        // On recupere l'indice du bus stop courant dans le tableau
        indice = getIndiceBusStop(numline, p->id_bus_stop);
        		
		if(p->sens_aller)
		{ 
		    fic<<"<p class=\"style1\">- Sens du trajet : Aller</p>"<<endl;
		    idNextBusstop     = (ligneBus[indice+1]).busStop.idBusStop;                   // on recupere le PROCHAIN bus stop
		    distanceRestante  = (ligneBus[indice]).distanceWithNextBusStop - p->distance; // on recupere le distance entre les bus stop
		    timeToNextBusStop = (ligneBus[indice]).timeToNextStop;                        // on recupere le temps entre les bus stop
		    distanceEntreArret= (ligneBus[indice]).distanceWithNextBusStop;
		}
		else
		{
			fic<<"<p class=\"style1\">- Sens du trajet : Retour</p>"<<endl;
			idNextBusstop     = (ligneBus[indice-1]).busStop.idBusStop;                     // on recupere le PROCHAIN bus stop
		    distanceRestante  = (ligneBus[indice-1]).distanceWithNextBusStop - p->distance; // on recupere le distance entre les bus stop
		    timeToNextBusStop = (ligneBus[indice-1]).timeToNextStop;                        // on recupere le temps entre les bus stop
		    distanceEntreArret= (ligneBus[indice-1]).distanceWithNextBusStop;
		}
		
		if( (ligneBus[indice]).busStop.obligatory == true )
		{
			fic<<"<p class=\"style1\">- Distance entre les BusStops : "<< distanceEntreArret * 1000<<" m</p>"<<endl;
			fic<<"<p class=\"style1\">- Temps de parcours entre les BusStops : "<<timeToNextBusStop * 60<<" secondes</p>"<<endl;
			fic<<"<p class=\"style1\"> - Distance restante avant le prochain arret : "<< distanceRestante * 1000<<" m</p>"<<endl;
	    		sch.waiting_time = distanceRestante / speed; // le waiting_time est en seconde
	    		fic<<"<p class=\"style1\"> - Temps restant avant le prochain arret : "<<sch.waiting_time*3600<<" secondes</p>"<<endl;
			if(sch.waiting_time * 60 < timeToNextBusStop * 60 - p->time )
	    		{
				if(speed==50)
				{
					fic<<"<p class=\"style1\">- Etat du bus : Le bus est au maximum de sa vitesse (50km/h)</p></td>"<<endl;
				}
				else
				{
					fic<<"<p class=\"style1\">- Etat du bus : Le bus est en retard, il va accelerer... </p></td>"<<endl;
				}
	    		} 
			else if(sch.waiting_time * 60 > timeToNextBusStop * 60 - p->time)
		    	{
		    		fic<<"<p class=\"style1\">- Etat du bus : Le bus est en avance, il va ralentir... </p></td>"<<endl;
			} 
			else if (sch.waiting_time * 60 == timeToNextBusStop * 60 - p->time)
		    	{
		    		fic<<"<p class=\"style1\">- Etat du bus : Le bus est dans les temps, il conserve sa vitesse... </p></td>"<<endl;
			}
			if(p->distance==0)
			{
				idbusstopatteint=p->id_bus_stop;
				//fic<<"======= I'm arrived to the BusStop " <<p->id_bus_stop<<"  ============<br>"<<endl;	
			}
			else
			idbusstopatteint=0;
			
			
		}
		fic<<"<td width=\"386\" bordercolor=\"#000000\"><p>Cliquez sur le BusStop pour acc&eacute;der &agrave; ses informations </p>"<<endl;
		fic<<"<div align=\"center\">"<<endl;
		fic<<"<table width=\"390\" border=\"0\">"<<endl;
		unsigned int indiceBusStop;
    		if (p->sens_aller)
    		{
	    		for (unsigned int k = 0; k< ligneBus.size() ; k++)	
	    		{
				indiceBusStop =ligneBus[k].busStop.idBusStop;
				if (indiceBusStop==idbusstopatteint)
				fic<<"<tr><td width=\"75\"><img src=\"pics/fleche.gif\" width=\"66\" height=\"40\"></td>"<<endl;
				else
				fic<<"<tr><td width=\"75\"></td>"<<endl;
				fic<<"<td width=\"99\"><a href=arret"<<indiceBusStop<<".html><img src=\"pics/BusStop.jpg\" alt=\"Bus Stop "<<indiceBusStop<<"\" width=\"34\" height=\"54\"><span class=\"style3\">n&deg;"<<indiceBusStop<<"</span></a></td>"<<endl;
	    		if(k< ligneBus.size())
	    		{k++;
	    		indiceBusStop =ligneBus[k].busStop.idBusStop;
				if (indiceBusStop==idbusstopatteint)
				fic<<"<td width=\"75\"><img src=\"pics/fleche.gif\" width=\"66\" height=\"40\"></td>"<<endl;
				else
				fic<<"<td width=\"75\"></td>"<<endl;
				fic<<"<td width=\"99\"><a href=arret"<<indiceBusStop<<".html><img src=\"pics/BusStop.jpg\" alt=\"Bus Stop "<<indiceBusStop<<"\" width=\"34\" height=\"54\"><span class=\"style3\">n&deg;"<<indiceBusStop<<"</span></a></td><tr>"<<endl;
	    		}
	    		}
    		}
	   	else
	    	{
	    		for (int k = ligneBus.size()-1; k >=0 ; k--)	
	    		{
				indiceBusStop =ligneBus[k].busStop.idBusStop;
				if (indiceBusStop==idbusstopatteint)
				fic<<"<tr><td width=\"75\"><img src=\"pics/fleche.gif\" width=\"66\" height=\"40\"></td>"<<endl;
				else
				fic<<"<tr><td width=\"75\"></td>"<<endl;
				fic<<"<td width=\"99\"><a href=arret"<<indiceBusStop<<".html><img src=\"pics/BusStop.jpg\" alt=\"Bus Stop "<<indiceBusStop<<"\" width=\"34\" height=\"54\"><span class=\"style3\">n&deg;"<<indiceBusStop<<"</span></a></td>"<<endl;
	    		if(k< ligneBus.size())
	    		{k--;
	    		indiceBusStop =ligneBus[k].busStop.idBusStop;
				if (indiceBusStop==idbusstopatteint)
				fic<<"<td width=\"75\"><img src=\"pics/fleche.gif\" width=\"66\" height=\"40\"></td>"<<endl;
				else
				fic<<"<td width=\"75\"></td>"<<endl;
				fic<<"<td width=\"99\"><a href=arret"<<indiceBusStop<<".html><img src=\"pics/BusStop.jpg\" alt=\"Bus Stop "<<indiceBusStop<<"\" width=\"34\" height=\"54\"><span class=\"style3\">n&deg;"<<indiceBusStop<<"</span></a></td><tr>"<<endl;
	    		}
	    		}    
	    	}
		fic<<"</table></div></tr></table>"<<endl;
		fic<<"</BODY></HTML>"<<endl;
		fic.close(); 		
		}
		catch (exception e){
		
		}
	
}

//Initialisation du singleton
OperatingCenter* OperatingCenter::single = NULL;
